home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11823 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.5 KB

  1. Path: mydata.se!janm
  2. From: janm@mydata.se (Jan Mattsson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Coding Standards
  5. Date: 16 Mar 96 11:44:19 GMT
  6. Organization: MYDATA automation AB
  7. Distribution: world
  8. Message-ID: <janm.826976659@mydata.se>
  9. References: <4hj8ek$elu@sam.inforamp.net> <4hktar$5o2@galaxy.ucr.edu> <4hmqol$97j@abacus.abasoft.co.uk> <4hsg8r$pmm@sam.inforamp.net> <4i9o6j$p4l@daisy.pgh.wec.com> <4idskb$pc1@sam.inforamp.net>
  10. Reply-To: janm@mydata.se
  11. NNTP-Posting-Host: cray2b.mydata.se
  12. Organisation: None
  13. X-Newsreader: NN version 6.5.0 #1 (NOV)
  14.  
  15. rmorin@inforamp.net (Randy Charles Morin) writes:
  16.  
  17. >    -do not use the /* */ comment, except when commenting out entire 
  18. >sections of code.  
  19. >    /* */ are the ANSI standard comment.
  20.  
  21. As you may or may not know, there is no ANSI standard yet.
  22. This is what the draft standard says on the subject of comments:
  23.  
  24. 1 The  characters  /* start a comment, which terminates with the charac-
  25.   ters */.  These comments do not nest.  The characters // start a  com-
  26.   ment, which terminates with the next new-line character. If there is a
  27.   form-feed or a vertical-tab character in such a comment,  only  white-
  28.   space  characters shall appear between it and the new-line that termi-
  29.   nates the comment; no diagnostic is required.  The comment  characters
  30.   //,  /*,  and  */  have no special meaning within a // comment and are
  31.   treated just like other characters.  Similarly, the comment characters
  32.   // and /* have no special meaning within a /* comment.
  33.  
  34. Satisfied?
  35. How about actually reading the bl**dy standard before you
  36. start telling us what's ANSI and what's not?
  37.  
  38.  
  39. >    -a class which can be instantiated with a "new" must have a copy 
  40. >constructor, a destructor and an assignment operator definition.  
  41. >    Most compilers (if not all) supply default copy construtors.  Unless 
  42. >you think your class may have copy behavior problems, then writing copy 
  43. >constructors is redundant.  When you have 100+ classes to write and where the 
  44. >average copy constructor has 50 lines, you would need 100 hours to write the 
  45. >additional robustness (or cumbersomeness).
  46.  
  47. If your average class has 50 attributes you need to work on your design.
  48. Even if that is the case, I fail to see how it can take an hour to type
  49. 50 trivial lines. You could even write a little script, emacs macro or
  50. whatever to do it for you if you think it's so hard.
  51.  
  52.  
  53. >    -optimize code only when you have a problem.  
  54. >    Why not anticipate the problem?    
  55.  
  56. Because premature "optimization" leads to unmaintainable code,
  57. and wastes effort that could have been put to better use.
  58.  
  59.  
  60. Jan Mattsson
  61.  
  62.  
  63.